package com.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.domain.Goods;
import com.service.goodsService;

/**
 * 
 * 功能描述：商品详情Servlet 查找到需要的商品并返回     查询到商品存入session
 * 	
 * Version： 1.0
 * 
 * date： 2016年6月23日 上午11:22:04
 * 
 * @author：XiaoBingBy
 *
 */
public class goodsDetailsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public goodsDetailsServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String goods_id = request.getParameter("goods_id");	//获取的商品ID
		System.out.println(request.getParameter("goods_id")+"----------------");
		
		//把数据封装到这个JavaBean 中
		Goods goods = new Goods();
		goods.setGoods_id(goods_id);
		
		//调用业务方法  完成商品的查询  存入 
		goodsService goodsService = new goodsService();
		Goods goodsInfo = goodsService.getGoodsInfo(goods);
		HttpSession session = request.getSession();
		session.setAttribute("goodsInfo", goodsInfo);
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
